package cn.hairui.blog.repository;

import cn.hairui.blog.mapper.CategoryMapper;
import cn.hairui.blog.model.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author lihairui
 * @version V1.0
 * @date: 2019/7/28 20:13
 */
@Repository
public class CategoryRepository {

    @Autowired
    private CategoryMapper categoryMapper;

    public List<Category> findByIsShow(String isShow) {
        return categoryMapper.findByIsShow(isShow);
    }

    public Category find(int categoryId) {
        return categoryMapper.find(categoryId);
    }

    public List<Map> findCountList() {
        return categoryMapper.findCountList();
    }

    public List<Category> list() {
        return categoryMapper.list();
    }

    public List<Map> listMgr() {
        return categoryMapper.listMgr();
    }

    public void updateIsShow(int id, String flag) {
        categoryMapper.updateIsShow(id, flag);
    }

    public int add(Category category) {
        categoryMapper.insert(category);
        return category.getId();
    }

    public int findMaxOrder() {
        return categoryMapper.findMaxOrder();
    }

    public void delelte(Category category) {
        categoryMapper.delete(category);
    }

    public void update(Category category) {
        categoryMapper.updateByPrimaryKey(category);
    }

    public void updateShowOrder(int id, int orderNo) {
        categoryMapper.updateShowOrder(id, orderNo);
    }
}
